<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;

use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use Illuminate\Http\Request;

class WechatMenuController extends Controller
{
    use ModelForm;
    public function index(){
        return Admin::content(function(Content $content){
            $content->description('微信菜单');
            $content->header('微信自定义菜单');
            $content->body(view('administrator.wechat.menu'));
        });
    }
    public function save(Request $request){
       // dd($request->all());
        $buttons=$request->menu;
      //  dd(\GuzzleHttp\json_decode($menu));
        $app=app('wechat');
        $menu=$app->menu;
        $buttons= \GuzzleHttp\json_decode($buttons,true);
      //  dd($buttons);
        $menu->add($buttons['menu']);

        return \Response::json([
            'flag'=>true
        ]);
    }
}
